'use strict'
const path = require('path')
const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');

function resolve(dir) {
    return path.join(__dirname, dir)
}

const name = "vant手机端"

module.exports = {

    publicPath: "/weapp/",
    outputDir: "dist",
    lintOnSave: false,
    productionSourceMap: false,
    filenameHashing: false,

    devServer: {
        host: "localhost",
        public: '192.168.0.103:8080',
        port: 8000,
        overlay: {
            warnings: false,
            errors: true
        },
        https: false,
        disableHostCheck: true,
        proxy: {
            [process.env.VUE_APP_BASE_API]: {
                target: 'http://tzcjj.sjzftkj.cn/',
                changeOrigin: true,
                pathRewrite: {
                    ['^' + process.env.VUE_APP_BASE_API]: '/'
                }
            },

            // '/apis': {     //这里是公共部分，在调用接口时后面接不相同的部分，/api就相当于http://192.168.0.199:8926/api这一段
            //     // target: 'https://apis.map.qq.com/',   //这里写的是访问接口的域名和端口号
            //     // target: 'https://wzgl.mofcom.gov.cn',   //这里写的是访问接口的域名和端口号
            //     target: 'http://tzcjj.sjzftkj.cn/',
            //     changeOrigin: true, // 必须加上这个才能跨域请求
            //     pathRewrite: {  // 重命名
            //         '^/apis': ''
            //     }
            // }

        }
    },
    css: {
        loaderOptions: {
            postcss: {
                plugins: [
                    autoprefixer(),
                    pxtorem({
                        rootValue: 37.5,
                        propList: ['*']
                    })
                ]
            }
        },

    },
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            // console.log('生产环境console')
            config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
            config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
            config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
            config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
        }
        var obj = {
            name: name,
            resolve: {
                alias: {
                    '@': resolve('src')
                }
            },
        };
        return obj;
    }
}
